package com.zlxtk.ling.nao;

import com.zlxtk.ling.po.Jue;
import com.zlxtk.ling.qiGuan.QiGuanType;

import java.util.List;
import java.util.UUID;

/**
 * 大脑功能区域
 */
public abstract class Nao extends Thread{

    private String id;

    public Nao() {
        this.id= UUID.randomUUID().toString().replaceAll("-", "");
    }


    /**
     * 从inputZhongShu获取数据，并初步处理
     */
    @Override
    public void run() {
        while (true){
            //拿到当前数据
            InputZhongShu inputZhongShu = InputZhongShu.getInstance();
            List<Jue> jueList = inputZhongShu.getJueListByQiguanType(getType());

            //处理数据
            try {
                handleData(jueList);
                // yield();
                sleep(1);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    //获取脑处理数据的类型
    public abstract QiGuanType getType();

    /**
     * 处理当前数据
     * @return
     */
    public abstract void handleData(List<Jue> jueList) throws Exception;
}
